<div class="vheader">
    <h1><?php echo $this->translate("Loan application") ?></h1>
    <p><?php echo $this->replaceEmpty($this->Applications->d->ClientFullName,$this->Applications->d->GroupName) ?>
</div>

<div class="vcontent dd160">    
    <dl class="horizontal" background-color: silver">
        <?php foreach($this->Applications->r->loans as $loan) : ?>
        <li>
        <dt><img style="border: 1px solid #bcd; margin-top: 5px;"  src="/default/photo/thumb/cat/i/id/<?php echo $loan->ClientId ?>" /></dt>        
        <dd>
            <?php echo $this->link('/loan/loan/view', array('id'=>$loan->LoanId),$loan->ClientFullName, array('id' => 'LnkViewLoan.'.$loan->LoanId)) ?><br />
            <?php echo $this->link('/loan/loan/status-changes', array('id'=>$loan->LoanId),$loan->LoanId . '/' . $loan->Status, array('id' => 'LnkStatusChanges.'.$loan->LoanId)) ?> - 
            <?php echo $this->link('/loan/loan/plan', array('id'=>$loan->LoanId),$loan->Principal, array('id' => 'LnkPaymentPlan.'.$loan->LoanId)) ?>  <br />
            <?php if(isset($this->SurveysCompleted[$loan->LoanId])): ?>
                <img width="8px" src="/css/images/dotGreen.png"> <?php echo $this->translate("Survey completed") ?> <br />
            <?php else: ?>
                <img width="8px" src="/css/images/dotRed.png"> <?php echo $this->link('/survey/survey/apply', array('loan'=>$loan->LoanId),$this->translate("Complete survey"), array('id' => 'LnkApplySurvey.'.$loan->LoanId)) ?>  <br />
            <?php endif; ?>  
            
            <img width="8px" src="/css/images/dotRed.png"> <?php echo $this->link('/survey/survey/apply', array('loan'=>$loan->LoanId),$this->translate("Select business"), array('id' => 'LnkApplySurvey.'.$loan->LoanId)) ?>  <br />              
            <?php echo $this->translate("Delete") ?>
        </dd>
        </li>
    <?php endforeach; ?>
    </dl> 
</div>

<div class="vgrid">
    
    <div class="cell">
        <dl>
            <dt><?php echo $this->translate("Branch") ?></dt>
            <dd><?php echo $this->Applications->d->LocationName ?></dd>
            <dt><?php echo $this->translate("Community") ?></dt>
            <dd><?php echo $this->Applications->d->CommunityName ?></dd>
            <dt><?php echo $this->translate("Loan officer") ?></dt>
            <dd><?php echo $this->Applications->d->OfficerFullName ?></dd>
            <dt><?php echo $this->translate("Product line") ?></dt>
            <dd><?php echo $this->Applications->d->ProductLineName ?></dd>  
            <dt><?php echo $this->translate("Program name") ?></dt>
            <dd><?php echo $this->Applications->d->ProgramName ?></dd>
            <dt><?php echo $this->translate("Loan product") ?></dt>
            <dd><?php echo $this->Applications->d->LoanProductName ?></dd>
            <dt><?php echo $this->translate("Survey") ?></dt>
            <dd><?php echo $this->Applications->d->SurveyName ?></dd>
        </dl>    
    </div>
    
    <div class="cell">
        <dl>
            <dt><?php echo $this->translate("Master code") ?></dt>
            <dd><?php echo $this->Applications->d->LoanMasterId ?></dd> 
            <dt></dt><dd></dd> 
            <dt><?php echo $this->translate("Borrower") ?></dt>
            <dd><?php echo $this->replaceEmpty($this->Applications->d->ClientFullName,$this->Applications->d->GroupName) ?></dd>  
            <dt><?php echo $this->translate("Amount") ?></dt>
            <dd><?php echo $this->Applications->d->Amount ?></dd> 
            <dt><?php echo $this->translate("Installments") ?></dt>
            <dd><?php echo $this->Applications->d->Installments ?> / <?php echo $this->Applications->d->PaymentFrequency ?></dd> 
            <dt></dt><dd></dd>   
            <dt><?php echo $this->translate("Status") ?></dt>
            <dd><?php echo $this->Applications->d->Status ?></dd>  
            <dt><?php echo $this->translate("Check number") ?></dt>
            <dd><?php echo $this->Applications->d->CheckNumber ?></dd>
        </dl>    
    </div>
    
    <div class="cell">
        <dl>
            <dt><?php echo $this->translate("Tent. delivery date") ?></dt>
            <dd><?php echo $this->Applications->d->TentativeDeliveryDate ?></dd>
            <dt><?php echo $this->translate("Tent. 1st. pmt. date") ?></dt>
            <dd><?php echo $this->Applications->d->TentativeFirstPaymentDate ?></dd>
            <dt></dt><dd></dd>
            <dt><?php echo $this->translate("Delivery date") ?></dt>
            <dd><?php echo $this->Applications->d->DeliveryDate ?></dd>
            <dt><?php echo $this->translate("Exp. 1st. pmt. date") ?></dt>
            <dd><?php echo $this->Applications->d->ExpectedFirstPaymentDate ?></dd>
            <dt><?php echo $this->translate("Exp. cancel date") ?></dt>
            <dd><?php echo $this->Applications->d->ExpectedCancelDate ?></dd>
        </dl>    
    </div>

</div>

<!--
<div class="vgrid">
    <?php // echo $this->partial('partials/grid.phtml', $this->loanStatusChanges); ?>
</div>
-->    

<div class="vfooter">
    <div class="menu">
        <a>Change dates</a>
        <?php echo $this->link('/sponsor/donation-allocation/browse', array('LoanMasterId'=>$this->Applications->d->LoanMasterId),$this->translate("Sponsorship"),array('target'=>'bottom')) ?>
        <a>Approve</a>
        <a>Disburse</a>
        <a>Release</a>
        <a>Reject</a>
        <a>Retract</a>
        <?php echo $this->printLink() ?> 
    </div>
</div>


<!-- Tooltips -->
<div style="visibility: hidden">
    <?php foreach($this->Applications->r->loans as $loan) : ?>
    <div data-dojo-type="dijit.Tooltip" data-dojo-props="connectId:'LnkViewLoan.<?php echo $loan->LoanId ?>',position:['below']">
        <?php echo $this->translate("Click to view loan details") ?>
    </div>
    <div data-dojo-type="dijit.Tooltip" data-dojo-props="connectId:'LnkStatusChanges.<?php echo $loan->LoanId ?>',position:['below']">
        <?php echo $this->translate("Click to view status changes") ?>
    </div>
    <div data-dojo-type="dijit.Tooltip" data-dojo-props="connectId:'LnkPaymentPlan.<?php echo $loan->LoanId ?>',position:['below']">
        <?php echo $this->translate("Click to view payment plan") ?>
    </div>
    <div data-dojo-type="dijit.Tooltip" data-dojo-props="connectId:'LnkApplySurvey.<?php echo $loan->LoanId ?>',position:['below']">
        <?php echo $this->translate("Click to complete survey") ?>
    </div>
    <?php endforeach; ?>
</div>
